{{- define "rewrites" }}
rewrite ^/modules/[0-9]+-(?<module_doc>[^/]+/.*)$ /modules/$module_doc permanent;
rewrite ^(.*)/documentation(/(v[0-9]+|v[0-9]+\.[0-9]+|latest))?/security/kuma.html$ /products/kubernetes-platform/documentation$2/admin/configuration/security/kuma-and-av-software.html redirect;
rewrite ^(.*)/documentation(/(v[0-9]+|v[0-9]+\.[0-9]+|latest))?/oss_info.html$ /products/kubernetes-platform/documentation$2/reference/oss_info.html redirect;
rewrite ^(.*)/documentation(/(v[0-9]+|v[0-9]+\.[0-9]+|latest))?/module-development/(?<path>.*)$ /products/kubernetes-platform/documentation$2/architecture/module-development/$path redirect;
rewrite ^(.*)/documentation(/(v[0-9]+|v[0-9]+\.[0-9]+|latest))?/deckhouse-cli/(?<path>.*)$ /products/kubernetes-platform/documentation$2/cli/d8/$path redirect;
rewrite ^(.*)/documentation(/(v[0-9]+|v[0-9]+\.[0-9]+|latest))?/network_security_setup.html$ /products/kubernetes-platform/documentation$2/reference/network_interaction.html redirect;
rewrite ^(.*)/documentation(/(v[0-9]+|v[0-9]+\.[0-9]+|latest))?/revision-comparison.html$ /products/kubernetes-platform/documentation$2/reference/revision-comparison.html redirect;
rewrite ^(.*)/documentation(/(v[0-9]+|v[0-9]+\.[0-9]+|latest))?/alerts.html$ /products/kubernetes-platform/documentation$2/reference/alerts.html redirect;
rewrite ^(.*)/documentation(/(v[0-9]+|v[0-9]+\.[0-9]+|latest))?/deckhouse-configure-global.html$ /products/kubernetes-platform/documentation$2/reference/api/global.html redirect;
rewrite ^(.*)/documentation(/(v[0-9]+|v[0-9]+\.[0-9]+|latest))?/deckhouse-faq.html$ /products/kubernetes-platform/documentation$2/admin/configuration/ redirect;
rewrite ^(.*)/documentation(/(v[0-9]+|v[0-9]+\.[0-9]+|latest))?/deckhouse-overview.html$ /products/kubernetes-platform/documentation$2/admin/configuration/ redirect;
rewrite ^(.*)/documentation(/(v[0-9]+|v[0-9]+\.[0-9]+|latest))?/supported_versions.html$ /products/kubernetes-platform/documentation$2/reference/supported_versions.html redirect;
rewrite ^(.*)/documentation(/(v[0-9]+|v[0-9]+\.[0-9]+|latest))?/installing/configuration.html$ /products/kubernetes-platform/documentation$2/installing/ redirect;
rewrite ^/documentation/(.*)$ /products/kubernetes-platform/documentation/$1 permanent;
rewrite ^/products/kubernetes-platform/documentation/(?<doc_path>(?!v[0-9]+/|v[0-9]+\.[0-9]+/|latest/).*)$ /products/kubernetes-platform/documentation/v1/$doc_path redirect;
rewrite ^/gs/(.*)$ /products/kubernetes-platform/gs/$1 permanent;
rewrite ^/guides/(.*)$ /products/kubernetes-platform/guides/$1 permanent;
rewrite ^/products/kubernetes-platform/documentation$ /products/kubernetes-platform/documentation/ permanent;
rewrite ^/products/kubernetes-platform/gs$ /products/kubernetes-platform/gs/ permanent;
rewrite ^/products/kubernetes-platform/guides$ /products/kubernetes-platform/guides/ permanent;
rewrite ^/products/kubernetes-platform/platform/(.*)$ /products/kubernetes-platform/documentation/v1/$1 redirect;
rewrite ^/products/kubernetes-platform/modules/(.*)$ /modules/$1 redirect;
rewrite ^/products/kubernetes-platform/documentation/v1/modules/(.*)$ /modules/$1 redirect;
#rewrite ^/modules/(.*)$ /products/kubernetes-platform/modules/$1 permanent;
#rewrite ^/source/modules/(.*)$ /modules/$1 redirect;
rewrite ^/platform/(.*)$ /products/kubernetes-platform/documentation/v1/$1 redirect;
rewrite ^.*/documentation/v1/modules/490-virtualization/(examples|configuration|cr|faq).html(.*)$ /modules/virtualization/stable/$1.html$2 permanent;
rewrite ^.*/documentation/v1/modules/490-virtualization/.*$ /modules/virtualization/stable/ permanent;
#rewrite ^/products/kubernetes-platform/modules/csi-yadro/(.*)?$ /products/kubernetes-platform/modules/csi-yadro-tatlin-unified/$1 permanent;
#rewrite ^/products/kubernetes-platform/modules/sds-drbd/(.*)?$ /products/kubernetes-platform/modules/sds-replicated-volume/$1 permanent;
#rewrite ^/modules/([^./]+)/?$ /modules/$1/stable/ permanent;
rewrite ^(/en|/ru)?(/documentation/v1\.[0-9]+)\.[0-9]+(/.*)$ /products/kubernetes-platform$2$3 permanent;
rewrite ^/ru/terms-of-service\.html /ru/security-policy.html permanent;
rewrite ^/ru/cookie-policy\.html /ru/security-policy.html permanent;
rewrite ^/ru/privacy-policy\.html /ru/security-policy.html permanent;
rewrite ^/en/security-policy\.html /en/privacy-policy.html permanent;
{{- end }}
